home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-06 | 10.6 KB | 469 lines | [TEXT/CWIE] |
- // Checkboxes.cp
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <Sound.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Appearance.h>
-
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "DoScrap.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "ControlUtils.h"
- #include "DDocData.h"
- #include "EverythingEngine.h"
- #include "EverythingDoc.h"
-
- #include "Checkboxes.h"
-
-
- //----------
- void Checkboxes::Create (
- AMDoc* inDoc,
- DDocData* inData)
- {
- Checkboxes* winObj = new Checkboxes;
-
- if (winObj != nil) {
- winObj->Open (inDoc);
- winObj->ConnectToData (inData);
- }
- }
-
- //----------
- Checkboxes::Checkboxes ()
- {
- mData = nil;
- }
-
- //----------
- Checkboxes::~Checkboxes ()
- {
- }
-
- //----------
- EverythingEngine* Checkboxes::GetEngine ()
- {
- return (EverythingEngine*) mDoc->mEngine;
- }
-
- //----------
- void Checkboxes::Open (
- AMDoc* inDoc)
- {
- WindowPtr window;
- Handle wftb;
-
- mDoc = inDoc;
-
- window = GetNewCWindow (WIND_Checkboxes, nil, (WindowPtr) -1L);
- if (mDoc->mEngine->GetFilename () [0] != 0) {
- SetWTitle (window, mDoc->mEngine->GetFilename ());
- }
- mWindow = window;
- ((EverythingDoc*)mDoc)->mCheckboxesPtr = window;
-
- SetWindowKind (window, 'AM');
- SetWRefCon (window, (long) this);
- SetPort (window);
- SetInfo (window);
-
- wftb = ::GetResource ('Wftb', WIND_Checkboxes);
-
- CreateRootControl (window, &mRootControl);
-
- vScroll = nil;
- hScroll = nil;
-
-
- mStandard2Handle = ::GetNewControl (CNTL_Standard2, window);
- SetWindowItemFont (mStandard2Handle, wftb, 1);
-
- mXxHandle = ::GetNewControl (CNTL_Xx, window);
- SetWindowItemFont (mXxHandle, wftb, 2);
-
- mCapTriangleLabel = GetNewControl (CNTL_CapTriangle, window);
- SetWindowItemFont (mCapTriangleLabel, wftb, 3);
- SetControlFromTEXT (mCapTriangleLabel, TEXT_CapTriangle);
-
-
- mGraphic2Handle = ::GetNewControl (CNTL_Graphic2, window);
- SetWindowItemFont (mGraphic2Handle, wftb, 4);
-
- mCapcicn2Label = GetNewControl (CNTL_Capcicn2, window);
- EmbedControl (mCapcicn2Label, mGraphic2Handle);
- SetWindowItemFont (mCapcicn2Label, wftb, 5);
- SetControlFromTEXT (mCapcicn2Label, TEXT_Capcicn2);
-
- mLRHandle = ::GetNewControl (CNTL_LR, window);
- EmbedControl (mLRHandle, mGraphic2Handle);
- SetWindowItemFont (mLRHandle, wftb, 6);
-
- mCapicl10Label = GetNewControl (CNTL_Capicl10, window);
- EmbedControl (mCapicl10Label, mGraphic2Handle);
- SetWindowItemFont (mCapicl10Label, wftb, 7);
- SetControlFromTEXT (mCapicl10Label, TEXT_Capicl10);
-
- mLR2Handle = ::GetNewControl (CNTL_LR2, window);
- EmbedControl (mLR2Handle, mGraphic2Handle);
- SetWindowItemFont (mLR2Handle, wftb, 8);
-
- mCapICN2Label = GetNewControl (CNTL_CapICN2, window);
- EmbedControl (mCapICN2Label, mGraphic2Handle);
- SetWindowItemFont (mCapICN2Label, wftb, 9);
- SetControlFromTEXT (mCapICN2Label, TEXT_CapICN2);
-
- mLR3Handle = ::GetNewControl (CNTL_LR3, window);
- EmbedControl (mLR3Handle, mGraphic2Handle);
- SetWindowItemFont (mLR3Handle, wftb, 10);
-
- mCapPICT2Label = GetNewControl (CNTL_CapPICT2, window);
- EmbedControl (mCapPICT2Label, mGraphic2Handle);
- SetWindowItemFont (mCapPICT2Label, wftb, 11);
- SetControlFromTEXT (mCapPICT2Label, TEXT_CapPICT2);
-
- mLR4Handle = ::GetNewControl (CNTL_LR4, window);
- EmbedControl (mLR4Handle, mGraphic2Handle);
- SetWindowItemFont (mLR4Handle, wftb, 12);
-
- mCheckboxHandle = ::GetNewControl (CNTL_Checkbox, window);
- EmbedControl (mCheckboxHandle, mGraphic2Handle);
- SetWindowItemFont (mCheckboxHandle, wftb, 13);
-
- mCapicl11Label = GetNewControl (CNTL_Capicl11, window);
- EmbedControl (mCapicl11Label, mGraphic2Handle);
- SetWindowItemFont (mCapicl11Label, wftb, 14);
- SetControlFromTEXT (mCapicl11Label, TEXT_Capicl11);
-
-
- mBevel2Handle = ::GetNewControl (CNTL_Bevel2, window);
- SetWindowItemFont (mBevel2Handle, wftb, 15);
-
- mCheckbox2Handle = ::GetNewControl (CNTL_Checkbox2, window);
- EmbedControl (mCheckbox2Handle, mBevel2Handle);
- SetWindowItemFont (mCheckbox2Handle, wftb, 16);
- SetBevelButtonGraphicAlignment (mCheckbox2Handle, kControlBevelButtonAlignCenter, 0, 0);
-
- mNext3Handle = ::GetNewControl (CNTL_Next3, window);
- EmbedControl (mNext3Handle, mBevel2Handle);
- SetWindowItemFont (mNext3Handle, wftb, 17);
- SetBevelButtonTextPlacement (mNext3Handle, kControlBevelButtonPlaceToRightOfGraphic);
- SetBevelButtonTextAlignment (mNext3Handle, kControlBevelButtonAlignTextFlushLeft, 0);
- SetBevelButtonGraphicAlignment (mNext3Handle, kControlBevelButtonAlignLeft, 0, 0);
-
- mNext4Handle = ::GetNewControl (CNTL_Next4, window);
- EmbedControl (mNext4Handle, mBevel2Handle);
- SetWindowItemFont (mNext4Handle, wftb, 18);
- SetBevelButtonTextPlacement (mNext4Handle, kControlBevelButtonPlaceBelowGraphic);
- SetBevelButtonTextAlignment (mNext4Handle, kControlBevelButtonAlignTextCenter, 0);
- SetBevelButtonGraphicAlignment (mNext4Handle, kControlBevelButtonAlignTop, 0, 0);
-
- AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- }
-
- //----------
- void Checkboxes::Close ()
- {
- mData->RemoveResponder (this);
-
- ((EverythingDoc*)mDoc)->mCheckboxesPtr = nil;
- SetInfo (nil);
- HideWindow (mWindow);
- DisposeWindow (mWindow);
-
- delete this;
- }
-
- //----------
- void Checkboxes::ConnectToData (
- DDocData* inData)
- {
- mData = inData;
- mData->AddResponder (this);
-
- SetControlValue (mStandard2Handle, mData->GetStandard ());
- SetControlValue (mXxHandle, mData->GetXx ());
- SetControlValue (mLRHandle, mData->GetLR ());
- SetControlValue (mLR2Handle, mData->GetLR2 ());
- SetControlValue (mLR3Handle, mData->GetLR3 ());
- SetControlValue (mLR4Handle, mData->GetLR4 ());
- SetControlValue (mCheckboxHandle, mData->GetCheckbox ());
- SetControlValue (mCheckbox2Handle, mData->GetCheckbox2 ());
- SetControlValue (mNext3Handle, mData->GetNext ());
- SetControlValue (mNext4Handle, mData->GetNext2 ());
- }
-
- //----------
- void Checkboxes::DataChanged (
- long inDataID)
- {
- if (inDataID == idStandard) {
- SetControlValue (mStandard2Handle, mData->GetStandard ());
- }
- if (inDataID == idXx) {
- SetControlValue (mXxHandle, mData->GetXx ());
- }
- if (inDataID == idLR) {
- SetControlValue (mLRHandle, mData->GetLR ());
- }
- if (inDataID == idLR2) {
- SetControlValue (mLR2Handle, mData->GetLR2 ());
- }
- if (inDataID == idLR3) {
- SetControlValue (mLR3Handle, mData->GetLR3 ());
- }
- if (inDataID == idLR4) {
- SetControlValue (mLR4Handle, mData->GetLR4 ());
- }
- if (inDataID == idCheckbox) {
- SetControlValue (mCheckboxHandle, mData->GetCheckbox ());
- }
- if (inDataID == idCheckbox2) {
- SetControlValue (mCheckbox2Handle, mData->GetCheckbox2 ());
- }
- if (inDataID == idNext) {
- SetControlValue (mNext3Handle, mData->GetNext ());
- }
- if (inDataID == idNext2) {
- SetControlValue (mNext4Handle, mData->GetNext2 ());
- }
- }
-
- //----------
- void Checkboxes::Control (
- ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
- short newValue;
-
- ExitCurField ();
-
- if (whichControl == mStandard2Handle) {
- if (TrackCheckbox (mStandard2Handle, where)) {
- mData->SetStandard (GetControlValue (mStandard2Handle) != 0);
- }
- }
- if (whichControl == mXxHandle) {
- if (TrackCheckbox (mXxHandle, where)) {
- mData->SetXx (GetControlValue (mXxHandle) != 0);
- }
- }
- if (whichControl == mLRHandle) {
- if (TrackCheckbox (mLRHandle, where)) {
- mData->SetLR (GetControlValue (mLRHandle) != 0);
- }
- }
- if (whichControl == mLR2Handle) {
- if (TrackCheckbox (mLR2Handle, where)) {
- mData->SetLR2 (GetControlValue (mLR2Handle) != 0);
- }
- }
- if (whichControl == mLR3Handle) {
- if (TrackCheckbox (mLR3Handle, where)) {
- mData->SetLR3 (GetControlValue (mLR3Handle) != 0);
- }
- }
- if (whichControl == mLR4Handle) {
- if (TrackCheckbox (mLR4Handle, where)) {
- mData->SetLR4 (GetControlValue (mLR4Handle) != 0);
- }
- }
- if (whichControl == mCheckboxHandle) {
- if (TrackCheckbox (mCheckboxHandle, where)) {
- mData->SetCheckbox (GetControlValue (mCheckboxHandle) != 0);
- }
- }
- if (whichControl == mCheckbox2Handle) {
- if (TrackClick (mCheckbox2Handle, where)) {
- mData->SetCheckbox2 (GetControlValue (mCheckbox2Handle) != 0);
- }
- }
- if (whichControl == mNext3Handle) {
- if (TrackClick (mNext3Handle, where)) {
- mData->SetNext (GetControlValue (mNext3Handle) != 0);
- }
- }
- if (whichControl == mNext4Handle) {
- if (TrackClick (mNext4Handle, where)) {
- mData->SetNext2 (GetControlValue (mNext4Handle) != 0);
- }
- }
- }
-
- //----------
- void Checkboxes::MouseIn (
- Point where,
- short modifiers)
- {
- Rect bounds;
-
- }
-
- //----------
- void Checkboxes::ExitCurField ()
- {
- ControlHandle focus;
-
- GetKeyboardFocus (mWindow, &focus);
-
- if (focus == nil) {
- // nothing to exit
-
- }
- }
-
- //----------
- void Checkboxes::TypeIn (
- char ch)
- {
- ControlHandle focus;
- SInt16 keyCode;
-
- GetKeyboardFocus (mWindow, &focus);
-
- if ((ch == charEnter)
- || (ch == charReturn)) {
- ExitCurField ();
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- DoTab ((curEvent.modifiers & optionKey) != 0);
- } else if (focus != nil) {
- keyCode = (SInt16)(curEvent.message & keyCodeMask);
- HandleControlKey (focus, keyCode, ch, (SInt16)curEvent.modifiers);
- mDoc->mEngine->SetDirty ();
- } else {
- SysBeep (1);
- }
- }
-
- //----------
- void Checkboxes::Resize ()
- {
- /* application-specific code to resize items in window */
- }
-
- //----------
- void Checkboxes::Scroll (
- short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == vScroll) {
- } else { // horizontal
- }
- }
-
- //----------
- void Checkboxes::DoUndo ()
- {
- } // DoUndo
-
- //----------
- void Checkboxes::DoCut ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TECut (curTE);
- mDoc->mEngine->SetDirty ();
- scrapDirty = true;
- }
- } // DoCut
-
- //----------
- void Checkboxes::DoCopy ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TECopy (curTE);
- scrapDirty = true;
- }
- } // DoCopy
-
- //----------
- void Checkboxes::DoPaste ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TEPaste (curTE);
- mDoc->mEngine->SetDirty ();
- }
- } // DoPaste
-
- //----------
- void Checkboxes::DoClear ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TEDelete (curTE);
- mDoc->mEngine->SetDirty ();
- }
- } // DoClear
-
- //----------
- void Checkboxes::DoSelectAll ()
- {
- TEHandle curTE = GetCurTE ();
-
- if (curTE != nil) {
- TESetSelect (0, 32767, curTE);
- }
- } // DoSelectAll
-
- //----------
- void Checkboxes::DoShowClipboard ()
- {
- } // DoShowClipboard
-
- //----------
- Boolean Checkboxes::DoCommand (
- long inCommand)
- {
- Boolean result = true;
-
- switch (inCommand) {
- case cmdUndo:
- DoUndo ();
- break;
- case cmdCut:
- DoCut ();
- break;
- case cmdCopy:
- DoCopy ();
- break;
- case cmdPaste:
- DoPaste ();
- break;
- case cmdClear:
- DoClear ();
- break;
- case cmdSelectAll:
- DoSelectAll ();
- break;
- case cmdShowClipboard:
- DoShowClipboard ();
- break;
-
- default:
- result = false;
- } // switch
-
- return result;
- }
-